package per.turtle.system.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import per.turtle.common.core.constant.ServiceNameConstants;
import per.turtle.common.core.web.entity.CommonResult;
import per.turtle.common.core.web.page.TableDataInfo;
import per.turtle.system.dto.LoginUser;
import per.turtle.system.entity.SysUser;
import per.turtle.system.feign.factory.RemoteUserFallbackFactory;

/**
 * 用户服务
 *
 * @author turtle
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {

    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @return 结果
     */
    @GetMapping("user/info/{username}")
    CommonResult<LoginUser> getUserInfo(@PathVariable("username") String username);

    /**
     * 获取用户列表或分页
     *
     * @param user 用户信息
     * @return 结果
     */
    @PostMapping("user/list")
    TableDataInfo<SysUser> selectUserList(@RequestBody SysUser user);

    /**
     * 根据用户id获取用户信息
     *
     * @param userId 用户id
     * @return 结果
     */
    @GetMapping("{userId}")
    CommonResult<LoginUser> selectUserById(@PathVariable("userId") String userId);

}
